<?php
/**
 * 摩玛
 *
 * @author lwb
 */
namespace app\wechat\controller;

class MomaFund extends Common {

    protected $config;
    protected $env = APP_ENV;

    public function __construct() {
        parent::__construct();
        $this->config = config('fund.' . $this->env);
    }
    
    //开通账户
    public function openAccount($params) { 
        //用户信息
        $userinfo = $this->getWS('ucenter', 'users@userInfo', ['u_code' => $this->uid]);

        //组装数据
        $data = [
            'ub_bank_name' => $userinfo['result']['ub_bank_name'],
            'u_true_name' => $userinfo['result']['u_true_name'],
            'u_name' => $userinfo['result']['ub_phone'],
            'u_ident_no' => $userinfo['result']['u_ident_no'],
            'ub_card_no' => $userinfo['result']['ub_card_no'],
            'back_url' => $this->config['back_url'],
        ];
        
        //电子账户信息
        $return = $this->getWS('channel', 'momafund@openAccount', $data);
        if($return['status'] != '2000'){
            $result = ['code' => 5000, 'msg' => '开通电子账户'];
            return $this->parse_data($result);
        }
        
        $result = ['data' => ['isJump' => true, 'content' => $return['result']]];

        return $this->parse_data($result);
    }
    
}
